package io.gitee.hchaojie.day04;

import java.util.Timer;
import java.util.TimerTask;

public class DemoTimer3 {
    // 匿名内部类
    TimerTask task1 = new TimerTask() {
        @Override
        public void run() {
            System.out.println("xxx...");
        }
    };

    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            System.out.println("...");
        }
    };

    public static void main(String[] args) {
        Timer timer = new Timer();

        // 匿名内部类
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                System.out.println("异步任务。。。");
            }
        };

        // timer.schedule(task, 1000);
        timer.schedule(new DemoTimer3().task1, 1000);
    }
}
